package routers

import (
	"github.com/gin-gonic/gin"
	"net/http"
	"sensi/app/api/service"
)

func serve(r *gin.Engine) {
	s := service.NewService()

	r.POST("/weather/composite", route(s.CompositeWeather))

	r.POST("/dial/preview", route(s.PreviewDial))
	r.POST("/dial/list", route(s.ListDials))
	r.POST("/dial/add", route(s.AddDial))
	r.POST("/dial/update", route(s.UpdateDial))
	r.POST("/dial/delete", route(s.DeleteDial))

	r.POST("/device/support", route(s.SupportDevice))
	r.POST("/device/list", route(s.ListDevices))
	r.POST("/device/add", route(s.AddDevice))
	r.POST("/device/update", route(s.UpdateDevice))
	r.POST("/device/delete", route(s.DeleteDevice))

	r.POST("/firmware-version/list", route(s.ListFirmwareVersions))
	r.POST("/firmware-version/add", route(s.AddFirmwareVersion))
	r.POST("/firmware-version/update", route(s.UpdateFirmwareVersion))
	r.POST("/firmware-version/delete", route(s.DeleteFirmwareVersion))
	r.POST("/firmware-version/compare", route(s.CompareFirmwareVersions))

	r.POST("/upload", route(s.Upload))
	r.StaticFS("/uploads/", http.Dir(service.FileDir))

	r.POST("/login", route(s.Login))
}
